package com.sevennotes.classtable.ui.pages.main_screen

import android.content.SharedPreferences
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.ExperimentalUnitApi
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.rememberNavController
import com.sevennotes.classtable.data.class_items.ClassesRespository
import com.sevennotes.classtable.ui.pages.MainNavHost
import com.sevennotes.classtable.ui.theme.ClassTableTheme
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.sevennotes.classtable.config.LAST_AUTO_SAVE_DATE
import com.sevennotes.classtable.config.Settings
import com.sevennotes.classtable.ui.theme.colorPaletteMaker
import java.util.Date

@ExperimentalUnitApi
@Composable
fun MainScreen(mainScreenViewModel: MainViewModel) {
    val navController = rememberNavController()
    val systemUiController = rememberSystemUiController()
    ClassTableTheme(
        colors = colorPaletteMaker(Settings.themeColor)
    ) {
        LaunchedEffect(Unit) {
            systemUiController.setSystemBarsColor(
                color = Settings.themeColor,
            )
        }
        Surface {
            MainNavHost(
                navController = navController,
                mainScreenViewModel = mainScreenViewModel
            )
        }
    }
}
